using HousingInfo.DataLinQ;

using System;
using System.Linq;
using Csla;
using Csla.Data;
using Csla.Security;
using Csla.Validation;

namespace HousingInfo.Library
{ 
	[Serializable()] 
	public partial class NewsHouseBO : Csla.BusinessBase<NewsHouseBO>
	{
		#region Business Properties and Methods
		//register properties
		private static PropertyInfo<int> NewsHouseIDProperty = RegisterProperty<int>(typeof(NewsHouseBO), new PropertyInfo<int>("NewsHouseID"));
		private static PropertyInfo<string> UserNameProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("UserName"));
		private static PropertyInfo<int?> AreaDetailIDProperty = RegisterProperty<int?>(typeof(NewsHouseBO), new PropertyInfo<int?>("AreaDetailID"));
		private static PropertyInfo<int?> CategoryIDProperty = RegisterProperty<int?>(typeof(NewsHouseBO), new PropertyInfo<int?>("CategoryID"));
		private static PropertyInfo<int?> CurrencyIDProperty = RegisterProperty<int?>(typeof(NewsHouseBO), new PropertyInfo<int?>("CurrencyID"));
		private static PropertyInfo<int?> HousingTypeIDProperty = RegisterProperty<int?>(typeof(NewsHouseBO), new PropertyInfo<int?>("HousingTypeID"));
		private static PropertyInfo<string> DocumentsProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("Documents"));
        private static PropertyInfo<decimal?> SurfaceAreaWidthProperty = RegisterProperty<decimal?>(typeof(NewsHouseBO), new PropertyInfo<decimal?>("SurfaceAreaWidth"));
        private static PropertyInfo<decimal?> SurfaceAreaHeightProperty = RegisterProperty<decimal?>(typeof(NewsHouseBO), new PropertyInfo<decimal?>("SurfaceAreaHeight"));
        private static PropertyInfo<bool?> SupMProperty = RegisterProperty<bool?>(typeof(NewsHouseBO), new PropertyInfo<bool?>("SupM"));
        private static PropertyInfo<string> HousesAddressProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("HousesAddress"));
		private static PropertyInfo<string> DirectionProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("Direction"));
		private static PropertyInfo<decimal?> PriceProperty = RegisterProperty<decimal?>(typeof(NewsHouseBO), new PropertyInfo<decimal?>("Price"));
		private static PropertyInfo<bool> IsNegotiationProperty = RegisterProperty<bool>(typeof(NewsHouseBO), new PropertyInfo<bool>("IsNegotiation"));
		private static PropertyInfo<DateTime> CreatedDateProperty = RegisterProperty<DateTime>(typeof(NewsHouseBO), new PropertyInfo<DateTime>("CreatedDate"));
		private static PropertyInfo<DateTime?> PostDateProperty = RegisterProperty<DateTime?>(typeof(NewsHouseBO), new PropertyInfo<DateTime?>("PostDate"));
		private static PropertyInfo<DateTime?> UpdatedDateProperty = RegisterProperty<DateTime?>(typeof(NewsHouseBO), new PropertyInfo<DateTime?>("UpdatedDate"));
		private static PropertyInfo<DateTime> ExpireDateProperty = RegisterProperty<DateTime>(typeof(NewsHouseBO), new PropertyInfo<DateTime>("ExpireDate"));
		private static PropertyInfo<string> TitleProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("Title"));
		private static PropertyInfo<string> NewsContentProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("NewsContent"));
		private static PropertyInfo<string> UrlImageProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("UrlImage"));
		private static PropertyInfo<int?> ViewCountProperty = RegisterProperty<int?>(typeof(NewsHouseBO), new PropertyInfo<int?>("ViewCount"));
		private static PropertyInfo<bool> IsExtensionProperty = RegisterProperty<bool>(typeof(NewsHouseBO), new PropertyInfo<bool>("IsExtension"));
		private static PropertyInfo<DateTime?> ExtensionDateProperty = RegisterProperty<DateTime?>(typeof(NewsHouseBO), new PropertyInfo<DateTime?>("ExtensionDate"));
		private static PropertyInfo<int?> NumExtensionProperty = RegisterProperty<int?>(typeof(NewsHouseBO), new PropertyInfo<int?>("NumExtension"));
		private static PropertyInfo<bool> IsPremiumProperty = RegisterProperty<bool>(typeof(NewsHouseBO), new PropertyInfo<bool>("IsPremium"));
		private static PropertyInfo<bool> IsAdvertisementProperty = RegisterProperty<bool>(typeof(NewsHouseBO), new PropertyInfo<bool>("IsAdvertisement"));
		private static PropertyInfo<string> UrlImageAdversitementProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("UrlImageAdversitement"));
		private static PropertyInfo<string> MessageProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("Message"));
		private static PropertyInfo<bool> IsActiveProperty = RegisterProperty<bool>(typeof(NewsHouseBO), new PropertyInfo<bool>("IsActive"));
		private static PropertyInfo<DateTime?> ActiveDateProperty = RegisterProperty<DateTime?>(typeof(NewsHouseBO), new PropertyInfo<DateTime?>("ActiveDate"));
		private static PropertyInfo<int?> NumPostProperty = RegisterProperty<int?>(typeof(NewsHouseBO), new PropertyInfo<int?>("NumPost"));
		private static PropertyInfo<DateTime?> UnActiveDateProperty = RegisterProperty<DateTime?>(typeof(NewsHouseBO), new PropertyInfo<DateTime?>("UnActiveDate"));
		private static PropertyInfo<DateTime?> ReActiveDateProperty = RegisterProperty<DateTime?>(typeof(NewsHouseBO), new PropertyInfo<DateTime?>("ReActiveDate"));

        private static PropertyInfo<bool> IsContactProperty = RegisterProperty<bool>(typeof(NewsHouseBO), new PropertyInfo<bool>("IsContact"));
        private static PropertyInfo<string> ContactNameProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("ContactName"));
        private static PropertyInfo<string> ContactAddressProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("ContactAddress"));
        private static PropertyInfo<string> ContactEmailProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("ContactEmail"));
        private static PropertyInfo<string> ContactPhoneProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("ContactPhone"));
        private static PropertyInfo<string> AddonsProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("Addons"));
        private static PropertyInfo<string> InteriorAmenitiesProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("InteriorAmenities"));
        private static PropertyInfo<string> SocialCultureProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("SocialCulture"));
        private static PropertyInfo<string> TempProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("Temp"));
        
        // lay cac truong chi tiet cua khoa ngoai
        private static PropertyInfo<string> CategoryNameProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("CategoryName"));
        private static PropertyInfo<string> AreaDetailNameProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("AreaDetailName"));
        private static PropertyInfo<string> AreaNameProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("AreaName"));
        private static PropertyInfo<string> CurrencyNameProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("CurrencyName"));
        private static PropertyInfo<string> HousingTypeNameProperty = RegisterProperty<string>(typeof(NewsHouseBO), new PropertyInfo<string>("HousingTypeName"));
        private static PropertyInfo<int> AreaIDProperty = RegisterProperty<int>(typeof(NewsHouseBO), new PropertyInfo<int>("AreaID"));
        //end
		[System.ComponentModel.DataObjectField(true, true)]

        public string CategoryName
        {
            get { return GetProperty<string>(CategoryNameProperty); }
            set { SetProperty<string>(CategoryNameProperty, value); }
        }

        public string AreaDetailName
        {
            get { return GetProperty<string>(AreaDetailNameProperty); }
            set { SetProperty<string>(AreaDetailNameProperty, value); }
        }

        public string AreaName
        {
            get { return GetProperty<string>(AreaNameProperty); }
            set { SetProperty<string>(AreaNameProperty, value); }
        }

        public string CurrencyName
        {
            get { return GetProperty<string>(CurrencyNameProperty); }
            set { SetProperty<string>(CurrencyNameProperty, value); }
        }
        public string HousingTypeName
        {
            get { return GetProperty<string>(HousingTypeNameProperty); }
            set { SetProperty<string>(HousingTypeNameProperty, value); }
        }

        public int AreaID
        {
            get { return GetProperty<int>(AreaIDProperty); }
        }

        //

		public int NewsHouseID
		{
			get { return GetProperty<int>(NewsHouseIDProperty); }
		}
	 
		public string UserName
		{
			get { return GetProperty<string>(UserNameProperty); }
			set { SetProperty<string>(UserNameProperty, value); }
		}
	 
		public int? AreaDetailID
		{
			get { return GetProperty<int?>(AreaDetailIDProperty); }
			set { SetProperty<int?>(AreaDetailIDProperty, value); }
		}
	 
		public int? CategoryID
		{
			get { return GetProperty<int?>(CategoryIDProperty); }
			set { SetProperty<int?>(CategoryIDProperty, value); }
		}
	 
		public int? CurrencyID
		{
			get { return GetProperty<int?>(CurrencyIDProperty); }
			set { SetProperty<int?>(CurrencyIDProperty, value); }
		}
	 
		public int? HousingTypeID
		{
			get { return GetProperty<int?>(HousingTypeIDProperty); }
			set { SetProperty<int?>(HousingTypeIDProperty, value); }
		}
	 
		public string Documents
		{
			get { return GetProperty<string>(DocumentsProperty); }
			set { SetProperty<string>(DocumentsProperty, value); }
		}

        public decimal? SurfaceAreaWidth
		{
            get { return GetProperty<decimal?>(SurfaceAreaWidthProperty); }
            set { SetProperty<decimal?>(SurfaceAreaWidthProperty, value); }
		}

        public decimal? SurfaceAreaHeight
        {
            get { return GetProperty<decimal?>(SurfaceAreaHeightProperty); }
            set { SetProperty<decimal?>(SurfaceAreaHeightProperty, value); }
        }

        public bool? SupM
        {
            get { return GetProperty<bool?>(SupMProperty); }
            set { SetProperty<bool?>(SupMProperty, value); }
        }

        public string HousesAddress
        {
            get { return GetProperty<string>(HousesAddressProperty); }
            set { SetProperty<string>(HousesAddressProperty, value); }
        }

		public string Direction
		{
			get { return GetProperty<string>(DirectionProperty); }
			set { SetProperty<string>(DirectionProperty, value); }
		}
	 
		public decimal? Price
		{
			get { return GetProperty<decimal?>(PriceProperty); }
			set { SetProperty<decimal?>(PriceProperty, value); }
		}
	 
		public bool IsNegotiation
		{
			get { return GetProperty<bool>(IsNegotiationProperty); }
			set { SetProperty<bool>(IsNegotiationProperty, value); }
		}
	 
		public DateTime CreatedDate
		{
			get { return GetProperty<DateTime>(CreatedDateProperty); }
			set { SetProperty<DateTime>(CreatedDateProperty, value); }
		}
	 
		public DateTime? PostDate
		{
			get { return GetProperty<DateTime?>(PostDateProperty); }
			set { SetProperty<DateTime?>(PostDateProperty, value); }
		}
	 
		public DateTime? UpdatedDate
		{
			get { return GetProperty<DateTime?>(UpdatedDateProperty); }
			set { SetProperty<DateTime?>(UpdatedDateProperty, value); }
		}
	 
		public DateTime ExpireDate
		{
			get { return GetProperty<DateTime>(ExpireDateProperty); }
			set { SetProperty<DateTime>(ExpireDateProperty, value); }
		}
	 
		public string Title
		{
			get { return GetProperty<string>(TitleProperty); }
			set { SetProperty<string>(TitleProperty, value); }
		}
	 
		public string NewsContent
		{
			get { return GetProperty<string>(NewsContentProperty); }
			set { SetProperty<string>(NewsContentProperty, value); }
		}
	 
		public string UrlImage
		{
			get { return GetProperty<string>(UrlImageProperty); }
			set { SetProperty<string>(UrlImageProperty, value); }
		}
	 
		public int? ViewCount
		{
			get { return GetProperty<int?>(ViewCountProperty); }
			set { SetProperty<int?>(ViewCountProperty, value); }
		}
	 
		public bool IsExtension
		{
			get { return GetProperty<bool>(IsExtensionProperty); }
			set { SetProperty<bool>(IsExtensionProperty, value); }
		}
	 
		public DateTime? ExtensionDate
		{
			get { return GetProperty<DateTime?>(ExtensionDateProperty); }
			set { SetProperty<DateTime?>(ExtensionDateProperty, value); }
		}
	 
		public int? NumExtension
		{
			get { return GetProperty<int?>(NumExtensionProperty); }
			set { SetProperty<int?>(NumExtensionProperty, value); }
		}
	 
		public bool IsPremium
		{
			get { return GetProperty<bool>(IsPremiumProperty); }
			set { SetProperty<bool>(IsPremiumProperty, value); }
		}
	 
		public bool IsAdvertisement
		{
			get { return GetProperty<bool>(IsAdvertisementProperty); }
			set { SetProperty<bool>(IsAdvertisementProperty, value); }
		}
	 
		public string UrlImageAdversitement
		{
			get { return GetProperty<string>(UrlImageAdversitementProperty); }
			set { SetProperty<string>(UrlImageAdversitementProperty, value); }
		}
	 
		public string Message
		{
			get { return GetProperty<string>(MessageProperty); }
			set { SetProperty<string>(MessageProperty, value); }
		}
	 
		public bool IsActive
		{
			get { return GetProperty<bool>(IsActiveProperty); }
			set { SetProperty<bool>(IsActiveProperty, value); }
		}
	 
		public DateTime? ActiveDate
		{
			get { return GetProperty<DateTime?>(ActiveDateProperty); }
			set { SetProperty<DateTime?>(ActiveDateProperty, value); }
		}
	 
		public int? NumPost
		{
			get { return GetProperty<int?>(NumPostProperty); }
			set { SetProperty<int?>(NumPostProperty, value); }
		}
	 
		public DateTime? UnActiveDate
		{
			get { return GetProperty<DateTime?>(UnActiveDateProperty); }
			set { SetProperty<DateTime?>(UnActiveDateProperty, value); }
		}
	 
		public DateTime? ReActiveDate
		{
			get { return GetProperty<DateTime?>(ReActiveDateProperty); }
			set { SetProperty<DateTime?>(ReActiveDateProperty, value); }
		}

        public bool IsContact
        {
            get { return GetProperty<bool>(IsContactProperty); }
            set { SetProperty<bool>(IsContactProperty, value); }
        }

        public string ContactName
        {
            get { return GetProperty<string>(ContactNameProperty); }
            set { SetProperty<string>(ContactNameProperty, value); }
        }

        public string ContactAddress
        {
            get { return GetProperty<string>(ContactAddressProperty); }
            set { SetProperty<string>(ContactAddressProperty, value); }
        }

        public string ContactEmail
        {
            get { return GetProperty<string>(ContactEmailProperty); }
            set { SetProperty<string>(ContactEmailProperty, value); }
        }

        public string ContactPhone
        {
            get { return GetProperty<string>(ContactPhoneProperty); }
            set { SetProperty<string>(ContactPhoneProperty, value); }
        }

        public string Addons
        {
            get { return GetProperty<string>(AddonsProperty); }
            set { SetProperty<string>(AddonsProperty, value); }
        }

        public string InteriorAmenities
        {
            get { return GetProperty<string>(InteriorAmenitiesProperty); }
            set { SetProperty<string>(InteriorAmenitiesProperty, value); }
        }

        public string SocialCulture
        {
            get { return GetProperty<string>(SocialCultureProperty); }
            set { SetProperty<string>(SocialCultureProperty, value); }
        }

        public string Temp
        {
            get { return GetProperty<string>(TempProperty); }
            set { SetProperty<string>(TempProperty, value); }
        }
	    
		#endregion //Business Properties and Methods

		#region Validation Rules
		protected override void AddBusinessRules()
		{
			//
			// UserName
			//
			//ValidationRules.AddRule(CommonRules.StringRequired, UserNameProperty);
			//ValidationRules.AddRule(CommonRules.StringMaxLength, new CommonRules.MaxLengthRuleArgs(UserNameProperty, 50));
			//
			// Documents
			//
			//ValidationRules.AddRule(CommonRules.StringMaxLength, new CommonRules.MaxLengthRuleArgs(DocumentsProperty, 50));
			//
			// Direction
			//
			//ValidationRules.AddRule(CommonRules.StringMaxLength, new CommonRules.MaxLengthRuleArgs(DirectionProperty, 50));
			//
			// Title
			//
			//ValidationRules.AddRule(CommonRules.StringRequired, TitleProperty);
			//ValidationRules.AddRule(CommonRules.StringMaxLength, new CommonRules.MaxLengthRuleArgs(TitleProperty, 100));
			//
			// NewsContent
			//
			//ValidationRules.AddRule(CommonRules.StringRequired, NewsContentProperty);
			//
			// UrlImage
			//
			//ValidationRules.AddRule(CommonRules.StringMaxLength, new CommonRules.MaxLengthRuleArgs(UrlImageProperty, 200));
			//
			// UrlImageAdversitement
			//
			//ValidationRules.AddRule(CommonRules.StringMaxLength, new CommonRules.MaxLengthRuleArgs(UrlImageAdversitementProperty, 200));

			AddCustomRules();
		}

		partial void AddCustomRules();
		#endregion //Validation Rules

		#region Factory Methods
		public static NewsHouseBO NewNewsHouseBO()
		{
			return DataPortal.Create<NewsHouseBO>();
		}

		public static NewsHouseBO GetNewsHouseBO(int newsHouseID)
		{
			return DataPortal.Fetch<NewsHouseBO>(new SingleCriteria<NewsHouseBO, int>(newsHouseID));
		}

		public static void DeleteNewsHouseBO(int newsHouseID)
		{
			DataPortal.Delete(new SingleCriteria<NewsHouseBO, int>(newsHouseID));
		}

		private NewsHouseBO()
		{ /* require use of factory method */ }

		public NewsHouseBO CopyNewsHouseBO()
		{
			NewsHouseBO objectCopy = this.Clone();
			objectCopy.MarkNew();
			return objectCopy;
		}
		#endregion //Factory Methods


		#region Data Access

		#region Data Access - Create
		[RunLocal]
		protected override void DataPortal_Create()
		{
			bool cancel = false;
			OnCreating(ref cancel);
			if (cancel) return;

			ValidationRules.CheckRules();

			//OnCreated();
		}

		partial void OnCreating(ref bool cancel);
		//partial void OnCreated();
		#endregion //Data Access - Create

		#region Data Access - Fetch
		private void DataPortal_Fetch(SingleCriteria<NewsHouseBO, int> criteria)
		{
			bool cancel = false;
			OnFetching(criteria, ref cancel);
			if (cancel) return;

			using (var mgr = ContextManager<HousingInfo.DataLinQ.HousingInfoDataContext>
						.GetManager(Database.HousingInfoConnection))
			{
				var data = mgr.DataContext.NewsHouses
						.Single(r => r.NewsHouseID == criteria.Value);

                var dataAreaDetailBO = mgr.DataContext.AreaDetails
                        .Single(r => r.AreaDetailID == data.AreaDetailID);
                var dataCurrencyBO = mgr.DataContext.Currencies
                        .Single(r => r.CurrencyID == data.CurrencyID);
                var dataCategoryBO = mgr.DataContext.Categories
                        .Single(r => r.CategoryID == data.CategoryID);
                var dataAreaBO = mgr.DataContext.Areas
                        .Single(r => r.AreaID == dataAreaDetailBO.AreaID);
                var dataHouseTypeBO = mgr.DataContext.HousingTypes
                        .Single(r => r.HousingTypeID == data.HousingTypeID);

				OnMemberLoading(data);

                LoadProperty<string>(CategoryNameProperty, dataCategoryBO.CategoryName);
                LoadProperty<string>(AreaDetailNameProperty, dataAreaDetailBO.AreaDetailName);
                LoadProperty<string>(AreaNameProperty, dataAreaBO.AreaName);
                LoadProperty<string>(CurrencyNameProperty, dataCurrencyBO.CurrencyName);
                LoadProperty<string>(HousingTypeNameProperty, dataHouseTypeBO.HousingTypeName);
                LoadProperty<int>(AreaIDProperty, dataAreaBO.AreaID);

				LoadProperty<int>(NewsHouseIDProperty, data.NewsHouseID);
				LoadProperty<string>(UserNameProperty, data.UserName);
				LoadProperty<int?>(AreaDetailIDProperty, data.AreaDetailID);
				LoadProperty<int?>(CategoryIDProperty, data.CategoryID);
				LoadProperty<int?>(CurrencyIDProperty, data.CurrencyID);
				LoadProperty<int?>(HousingTypeIDProperty, data.HousingTypeID);
				LoadProperty<string>(DocumentsProperty, data.Documents);
                LoadProperty<decimal?>(SurfaceAreaWidthProperty, data.SurfaceAreaWidth);
                LoadProperty<decimal?>(SurfaceAreaHeightProperty, data.SurfaceAreaHeight);
                LoadProperty<bool?>(SupMProperty, data.SupM);
                LoadProperty<string>(HousesAddressProperty, data.HousesAddress);
				LoadProperty<string>(DirectionProperty, data.Direction);
				LoadProperty<decimal?>(PriceProperty, data.Price);
				LoadProperty<bool>(IsNegotiationProperty, data.IsNegotiation);
				LoadProperty<DateTime>(CreatedDateProperty, data.CreatedDate);
				LoadProperty<DateTime?>(PostDateProperty, data.PostDate);
				LoadProperty<DateTime?>(UpdatedDateProperty, data.UpdatedDate);
				LoadProperty<DateTime>(ExpireDateProperty, data.ExpireDate);
				LoadProperty<string>(TitleProperty, data.Title);
				LoadProperty<string>(NewsContentProperty, data.NewsContent);
				LoadProperty<string>(UrlImageProperty, data.UrlImage);
				LoadProperty<int?>(ViewCountProperty, data.ViewCount);
				LoadProperty<bool>(IsExtensionProperty, data.IsExtension);
				LoadProperty<DateTime?>(ExtensionDateProperty, data.ExtensionDate);
				LoadProperty<int?>(NumExtensionProperty, data.NumExtension);
				LoadProperty<bool>(IsPremiumProperty, data.IsPremium);
				LoadProperty<bool>(IsAdvertisementProperty, data.IsAdvertisement);
				LoadProperty<string>(UrlImageAdversitementProperty, data.UrlImageAdversitement);
				LoadProperty<string>(MessageProperty, data.Message);
				LoadProperty<bool>(IsActiveProperty, data.IsActive);
				LoadProperty<DateTime?>(ActiveDateProperty, data.ActiveDate);
				LoadProperty<int?>(NumPostProperty, data.NumPost);
				LoadProperty<DateTime?>(UnActiveDateProperty, data.UnActiveDate);
				LoadProperty<DateTime?>(ReActiveDateProperty, data.ReActiveDate);
                LoadProperty<bool>(IsContactProperty, data.IsContact);
                LoadProperty<string>(ContactNameProperty, data.ContactName);
                LoadProperty<string>(ContactAddressProperty, data.ContactAddress);
                LoadProperty<string>(ContactEmailProperty, data.ContactEmail);
                LoadProperty<string>(ContactPhoneProperty, data.ContactPhone);
                LoadProperty<string>(AddonsProperty, data.Addons);
                LoadProperty<string>(InteriorAmenitiesProperty, data.InteriorAmenities);
                LoadProperty<string>(SocialCultureProperty, data.SocialCulture);
                LoadProperty<string>(TempProperty, data.Temp);
				//OnMemberLoaded();

				ValidationRules.CheckRules();
			}//using

			//OnFetched();
		}

		partial void OnFetching(SingleCriteria<NewsHouseBO, int> criteria, ref bool cancel);
		//partial void OnFetched();
		partial void OnMemberLoading(HousingInfo.DataLinQ.NewsHouse data);
		//partial void OnMemberLoaded();
		#endregion //Data Access - Fetch

		#region Data Access - Insert
		protected override void DataPortal_Insert()
		{
			bool cancel = false;
			OnInserting(ref cancel);
			if (cancel) return;

			using (var mgr = ContextManager<HousingInfo.DataLinQ.HousingInfoDataContext>
						.GetManager(Database.HousingInfoConnection))
			{
				var data = new HousingInfo.DataLinQ.NewsHouse();

				OnMemberReading(data);

				data.UserName = ReadProperty<string>(UserNameProperty);
				data.AreaDetailID = ReadProperty<int?>(AreaDetailIDProperty).Value;
				data.CategoryID = ReadProperty<int?>(CategoryIDProperty).Value;
				data.CurrencyID = ReadProperty<int?>(CurrencyIDProperty).Value;
				data.HousingTypeID = ReadProperty<int?>(HousingTypeIDProperty).Value;
				data.Documents = ReadProperty<string>(DocumentsProperty);
                data.SurfaceAreaWidth = ReadProperty<decimal?>(SurfaceAreaWidthProperty).Value;
                data.SurfaceAreaHeight = ReadProperty<decimal?>(SurfaceAreaHeightProperty).Value;
                data.SupM = ReadProperty<bool?>(SupMProperty);
                data.HousesAddress = ReadProperty<string>(HousesAddressProperty);
				data.Direction = ReadProperty<string>(DirectionProperty);
				data.Price = ReadProperty<decimal?>(PriceProperty).Value;
				data.IsNegotiation = ReadProperty<bool>(IsNegotiationProperty);
				data.CreatedDate = ReadProperty<DateTime>(CreatedDateProperty);
				data.PostDate = ReadProperty<DateTime?>(PostDateProperty);
				data.UpdatedDate = ReadProperty<DateTime?>(UpdatedDateProperty);
				data.ExpireDate = ReadProperty<DateTime>(ExpireDateProperty);
				data.Title = ReadProperty<string>(TitleProperty);
				data.NewsContent = ReadProperty<string>(NewsContentProperty);
				data.UrlImage = ReadProperty<string>(UrlImageProperty);
				data.ViewCount = ReadProperty<int?>(ViewCountProperty).Value;
				data.IsExtension = ReadProperty<bool>(IsExtensionProperty);
				data.ExtensionDate = ReadProperty<DateTime?>(ExtensionDateProperty);
				data.NumExtension = ReadProperty<int?>(NumExtensionProperty);
				data.IsPremium = ReadProperty<bool>(IsPremiumProperty);
				data.IsAdvertisement = ReadProperty<bool>(IsAdvertisementProperty);
				data.UrlImageAdversitement = ReadProperty<string>(UrlImageAdversitementProperty);
				data.Message = ReadProperty<string>(MessageProperty);
				data.IsActive = ReadProperty<bool>(IsActiveProperty);
				data.ActiveDate = ReadProperty<DateTime?>(ActiveDateProperty);
				data.NumPost = ReadProperty<int?>(NumPostProperty);
				data.UnActiveDate = ReadProperty<DateTime?>(UnActiveDateProperty);
				data.ReActiveDate = ReadProperty<DateTime?>(ReActiveDateProperty);
                data.IsContact = ReadProperty<bool>(IsContactProperty);
                data.ContactName = ReadProperty<string>(ContactNameProperty);
                data.ContactAddress = ReadProperty<string>(ContactAddressProperty);
                data.ContactEmail = ReadProperty<string>(ContactEmailProperty);
                data.ContactPhone = ReadProperty<string>(ContactPhoneProperty);
                data.Addons = ReadProperty<string>(AddonsProperty);
                data.InteriorAmenities = ReadProperty<string>(InteriorAmenitiesProperty);
                data.SocialCulture = ReadProperty<string>(SocialCultureProperty);
                data.Temp = ReadProperty<string>(TempProperty);
				AssignParentKey(data);
				//OnMemberRead();

				mgr.DataContext.NewsHouses.InsertOnSubmit(data);
				mgr.DataContext.SubmitChanges();

				LoadProperty<int>(NewsHouseIDProperty, data.NewsHouseID);
			}//using

			//OnInserted();
		}

		partial void OnInserting(ref bool cancel);
		//partial void OnInserted();
		partial void OnMemberReading(HousingInfo.DataLinQ.NewsHouse data);
		//partial void OnMemberRead();
		#endregion //Data Access - Insert

		#region Data Access - Update
		protected override void DataPortal_Update()
		{
			bool cancel = false;
			OnUpdating(ref cancel);
			if (cancel) return;

			using (var mgr = ContextManager<HousingInfo.DataLinQ.HousingInfoDataContext>
						.GetManager(Database.HousingInfoConnection))
			{
                //var data = new HousingInfo.DataLinQ.NewsHouse() 
                //{
                //    NewsHouseID = ReadProperty<int>(NewsHouseIDProperty)					
                //};
                //mgr.DataContext.NewsHouses.Attach(data);
                var data = mgr.DataContext.NewsHouses.Single(a => a.NewsHouseID == ReadProperty<int>(NewsHouseIDProperty));
                    OnMemberReading(data);
				if (IsSelfDirty)
				{
					data.UserName = ReadProperty<string>(UserNameProperty);
					data.AreaDetailID = ReadProperty<int?>(AreaDetailIDProperty).Value;
					data.CategoryID = ReadProperty<int?>(CategoryIDProperty).Value;
					data.CurrencyID = ReadProperty<int?>(CurrencyIDProperty).Value;
					data.HousingTypeID = ReadProperty<int?>(HousingTypeIDProperty).Value;
					data.Documents = ReadProperty<string>(DocumentsProperty);
                    data.SurfaceAreaWidth = ReadProperty<decimal?>(SurfaceAreaWidthProperty).Value;
                    data.SurfaceAreaHeight = ReadProperty<decimal?>(SurfaceAreaHeightProperty).Value;
                    data.SupM = ReadProperty<bool?>(SupMProperty);
                    data.HousesAddress = ReadProperty<string>(HousesAddressProperty);
					data.Direction = ReadProperty<string>(DirectionProperty);
					data.Price = ReadProperty<decimal?>(PriceProperty).Value;
					data.IsNegotiation = ReadProperty<bool>(IsNegotiationProperty);
					data.CreatedDate = ReadProperty<DateTime>(CreatedDateProperty);
					data.PostDate = ReadProperty<DateTime?>(PostDateProperty);
					data.UpdatedDate = ReadProperty<DateTime?>(UpdatedDateProperty);
					data.ExpireDate = ReadProperty<DateTime>(ExpireDateProperty);
					data.Title = ReadProperty<string>(TitleProperty);
					data.NewsContent = ReadProperty<string>(NewsContentProperty);
					data.UrlImage = ReadProperty<string>(UrlImageProperty);
					data.ViewCount = ReadProperty<int?>(ViewCountProperty).Value;
					data.IsExtension = ReadProperty<bool>(IsExtensionProperty);
					data.ExtensionDate = ReadProperty<DateTime?>(ExtensionDateProperty);
					data.NumExtension = ReadProperty<int?>(NumExtensionProperty);
					data.IsPremium = ReadProperty<bool>(IsPremiumProperty);
					data.IsAdvertisement = ReadProperty<bool>(IsAdvertisementProperty);
					data.UrlImageAdversitement = ReadProperty<string>(UrlImageAdversitementProperty);
					data.Message = ReadProperty<string>(MessageProperty);
					data.IsActive = ReadProperty<bool>(IsActiveProperty);
					data.ActiveDate = ReadProperty<DateTime?>(ActiveDateProperty);
					data.NumPost = ReadProperty<int?>(NumPostProperty);
					data.UnActiveDate = ReadProperty<DateTime?>(UnActiveDateProperty);
					data.ReActiveDate = ReadProperty<DateTime?>(ReActiveDateProperty);
                    data.IsContact = ReadProperty<bool>(IsContactProperty);
                    data.ContactName = ReadProperty<string>(ContactNameProperty);
                    data.ContactAddress = ReadProperty<string>(ContactAddressProperty);
                    data.ContactEmail = ReadProperty<string>(ContactEmailProperty);
                    data.ContactPhone = ReadProperty<string>(ContactPhoneProperty);
                    data.Addons = ReadProperty<string>(AddonsProperty);
                    data.InteriorAmenities = ReadProperty<string>(InteriorAmenitiesProperty);
                    data.SocialCulture = ReadProperty<string>(SocialCultureProperty);
                    data.Temp = ReadProperty<string>(TempProperty);
				}
				//OnMemberRead();

				mgr.DataContext.SubmitChanges();
				if (IsSelfDirty)
				{
					LoadProperty<int>(NewsHouseIDProperty, data.NewsHouseID);
				}
			}//using

			//OnUpdated();
		}
		partial void OnUpdating(ref bool cancel);
		//partial void OnUpdated();
		#endregion //Data Access - Update


		#region Data Access - Delete
		protected override void DataPortal_DeleteSelf()
		{
			bool cancel = false;
			OnSelfDeleting(ref cancel);
			if (cancel) return;

			using (var mgr = ContextManager<HousingInfo.DataLinQ.HousingInfoDataContext>
						.GetManager(Database.HousingInfoConnection))
			{
				OnMemberSelfDeleting();

				var data = new HousingInfo.DataLinQ.NewsHouse() 
				{
					NewsHouseID = ReadProperty<int>(NewsHouseIDProperty)
				};
				mgr.DataContext.NewsHouses.Attach(data);

				mgr.DataContext.NewsHouses.DeleteOnSubmit(data);
				OnMemberSelfDeleted();

				mgr.DataContext.SubmitChanges();
			}//using

			//OnSelfDeleted();
		}

		partial void OnSelfDeleting(ref bool cancel);
		//partial void OnSelfDeleted();
		partial void OnMemberSelfDeleting();
		partial void OnMemberSelfDeleted();

		private void DataPortal_Delete(SingleCriteria<NewsHouseBO, int> criteria)
		{
			bool cancel = false;
			OnDeleting(criteria, ref cancel);
			if (cancel) return;

			using (var mgr = ContextManager<HousingInfo.DataLinQ.HousingInfoDataContext>
						.GetManager(Database.HousingInfoConnection))
			{
				var data = mgr.DataContext.NewsHouses
						.Single(r => r.NewsHouseID == criteria.Value);

				OnMemberDeleting(data);

				mgr.DataContext.NewsHouses.DeleteOnSubmit(data);
				OnMemberDeleted();

				mgr.DataContext.SubmitChanges();
			}//using

			OnDeleted();
		}

		partial void OnDeleting(SingleCriteria<NewsHouseBO, int> criteria, ref bool cancel);
		partial void OnDeleted();
		partial void OnMemberDeleting(HousingInfo.DataLinQ.NewsHouse data);
		partial void OnMemberDeleted();
		#endregion //Data Access - Delete
		#endregion //Data Access

	}
}
